<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <meta charset="UTF-8">
    <title>编辑账户</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" type="text/css" href="/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="/h-ui.admin/css/style.css" />
    <![endif]-->
    <script type="text/javascript" src="/js/vue/vue.min.js"></script>
    <link rel="stylesheet" href="/js/laypage/skin/laypage.css">
    <script type="text/javascript" src="/js/laypage/laypage.js"></script>
    <link rel="stylesheet" href="/lib/layui/css/layui.css"  media="all">
</head>
<body>
<div class="page-container" data-validator-option="{theme:'simple_right'}">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><span class="c-red">*</span>供应商编号</label>
                <div class="layui-input-inline">
                    <input type="text" id="sup_number" name="sup_number" lay-verify="sup_number" autocomplete="off" class="layui-input" th:value='${supplier.supCompname}'>
                </div>
            </div>
            <input type="hidden" id="sup_id" th:value="${supplier.id}">
            <div class="layui-inline">
                <label class="layui-form-label"><span class="c-red">*</span>供应商名称</label>
                <div class="layui-input-inline">
                    <input type="text" id="sup_compname" name="sup_compname" lay-verify="sup_compname" autocomplete="off" value="" class="layui-input" th:value='${supplier.supCompname}'>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><span class="c-red">*</span>联系人</label>
                <div class="layui-input-inline">
                    <input type="text" id="sup_linkman" name="sup_linkman" lay-verify="sup_linkman" autocomplete="off" value="" class="layui-input" th:value='${supplier.supLinkman}'>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label"><span class="c-red">*</span>联系方式</label>
                <div class="layui-input-inline">
                    <input type="text" id="sup_tele" name="sup_tele" lay-verify="sup_tele" autocomplete="off" value="" class="layui-input" th:value='${supplier.supTele}'>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><span class="c-red">*</span>邮箱</label>
                <div class="layui-input-inline">
                    <input type="text" id="sup_email" name="sup_email" lay-verify="sup_email" autocomplete="off" value="" class="layui-input" th:value='${supplier.supEmail}'>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">关联人员</label>
                <div class="layui-input-inline">
                    <input type="text" id="sup_conn" name="sup_conn" lay-verify="sup_conn" autocomplete="off" value="" class="layui-input" th:value='${supplier.supConn}'>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="c-red">*</span>应付欠款</label>
            <div class="layui-input-block">
                <input type="text" id="sup_money" name="sup_money" lay-verify="sup_money" autocomplete="off" value="" class="layui-input" th:value='${supplier.supMoney}'>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <input id="textValue" type="hidden" th:value='${supplier.supRemarks}'>
                <textarea placeholder="说点什么..." cols="5" rows="3" id="sup_remarks" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">提交</button>
                <button type="reset" id="cancelBtn" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/lib/laypage/1.2/laypage.js"></script>
<script src="/lib/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var $ =layui.jquery;
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        //自定义验证规则
        form.verify({
            sup_compname:function(value){
                if(value.length < 1){
                    return '供应商名称不能为空啊';
                }
            },
            sup_money:function (value) {
                var check ='';
                if (value.length<1){
                    check='金额不能为空啊';
                };
                if (value.length>=1){
                    var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
                    var money = $('#sup_money').val();
                    if (!reg.test(money)){
                        check = '金额格式不对！'
                    }
                }
                return check;
            },
            sup_linkman:function (value) {
                if(value.length < 1){
                    return '联系人不能为空啊';
                }
            },
            sup_tele:function (value) {
                var check ='';
                if (value.length<1){
                    check='联系方式不能为空啊';
                };
                if (value.length>=1){
                    var reg=/^1[34578]\d{9}$/;
                    var tele = $('#sup_tele').val();
                    if (!reg.test(tele)){
                        check = '电话格式不对哦！'
                    }
                }
                return check;
            },
            sup_email:function (value) {
                var check ='';
                if (value.length<1){
                    check='邮箱不能为空啊';
                };
                if (value.length>=1){
                    var reg=/^[0-9a-zA-Z_.-]+[@][0-9a-zA-Z_.-]+([.][a-zA-Z]+){1,2}$/;
                    var email = $('#sup_email').val();
                    if (!reg.test(email)){
                        check = '邮箱格式不对哦！'
                    }
                }
                return check;
            }
        });
        var textarea = function(){
            var textVal = $("#textValue").val();
            $("#supRemarks").html(textVal);
        };
        textarea();
        form.render();

        //监听提交
        form.on('submit(demo1)', function(){
            $.ajax({
                type: "post",
                dataType: "json",
                url: "/customermanagement/supplier/updateSupplier",
                data: {
                    id:$("#sup_id").val(),
                    supCompname: $("#sup_compname").val(),
                    supNumber: $("#sup_number").val(),
                    supMoney: $("#sup_money").val(),
                    supTele: $("#sup_tele").val(),
                    supLinkman: $("#sup_linkman").val(),
                    supConn: $("#sup_conn").val(),
                    supEmail: $("#sup_email").val(),
                    supRemarks: $("#sup_remarks").val()
                },
                success: function(msg){
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }
            });
            return false;
        });
    });
</script>
</body>
</html>